<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class WarehouseOrderChild extends BaseModel
{
    use HasFactory;
    protected $table = 'warehouse_order_child';
    // 允许批量操作的字段
    protected $fillable = [
        'warehouse_order_id',
        'serial_number',
        'material_id',
        'num',
        'unit_price',
        'money',
        'remark',
        'created_at',
        'updated_at'
    ];

    public function scopeSearch($query,$params)
    {
//        if(!empty($params['warehouse_name'])){
//            $query->where('warehouse_name',$params['warehouse_name']);
//        }
        return $query;
    }

    public function material(){
        return $this->hasOne(Material::class,'id','material_id');
    }
}
